home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / util / rexx / rmh.lha / rmh / examples / notify.rexx < prev    next >
OS/2 REXX Batch file  |  1999-04-23  |  1KB  |  50 lines

  1. /*
  2.     Name:           notify.rexx
  3.     Template:       FILE,CLIP=CLIPUNIT/K/N,TIMEOUT/K/N
  4.     Description:    wait for a changes on a FILE or a CLIP with timeout
  5.                     default for CLIP is 0
  6.                     default for TIMEOUT is 10 seconds
  7. */
  8.  
  9. parm.1.value=0
  10. parm.2.value=10
  11.  
  12. if ~RMH_ReadArgs("FILE,CLIP=CLIPUNIT/K/N,TIMEOUT/K/N") then do
  13.     call PrintFault(IoErr(),ProgramName("NOEXT"))
  14.     exit
  15. end
  16.  
  17. if parm.1.value<0 | parm.2.value<0 | parm.2.value>100 then do
  18.     call PrintFault(115,ProgramName("NOEXT"))
  19.     exit
  20. end
  21.  
  22. if ~parm.0.flag | parm.1.flag then name="CLIP"
  23. else name=parm.0.value
  24.  
  25. if name=="CLIP" then noti=StartNotify(name,parm.1.value)
  26. else noti=StartNotify(name)
  27. if noti<0 then do
  28.     call PrintFault(IoErr(),ProgramName("NOEXT"))
  29.     exit
  30. end
  31. ns=NotifySignal(noti)
  32.  
  33. timer=CreateTimer()
  34. ts=TimerSignal(timer)
  35.  
  36. call StartTimer(timer,parm.2.value)
  37. mask=wait(or(ns,ts))
  38. if and(mask,ns)~=0 then do
  39.     if name=="CLIP" then do
  40.         say "Clip unit" parm.1.value "changed"
  41.         if ReadTextClip("C")~=0 then do
  42.             say "Clip unit" parm.1.value "content is:"
  43.             say c
  44.         end
  45.     end
  46.     else say "File:" name "changed"
  47. end
  48. else if and(mask,ts)~=0 then say "Timeout"
  49. call FreeNotify(noti)
  50.